<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>客户反馈系统-文章发表</title>
<meta name="viewport" content="width=device-width,initial-scale=1.0">

<link href="/ksp/layui/css/layui.css" rel="stylesheet">

<script type="text/javascript" src="/ksp/jquery/jquery.min.js"></script>
<script type="text/javascript" src="/ksp/layui/layui.all.js"></script>
<script type="text/javascript" src="/ksp/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="/ksp/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript" src="/ksp/ueditor/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript" src="/ksp/js/ksp.com.js"></script>

<script type="text/javascript">
	var element;
	var form;
	var layer;

	layui.use(["element", "form", "layer"], function() {
		element = layui.element;
		form = layui.form;
		layer = layui.layer;
	})
	function loginchk() {
		$.ajax({
			 url : "/ksp/usr/KSPU02"
			,type : "get"
			,dataType : "json"
			,data : {"COO_TKN" : getCookie("COO_TKN")}
			,async : true
			,success : function(res) {
				if (res.cod == "400") {
					alert(res.msg);
					window.location.href = "/ksp/p/usr/usrlgn";
				}
			}
			
		});	
	}
	
	
	function iniform() {
		UE.getEditor("CON_CON", {
			toolbars : [[ 'source', '|', 'undo', 'redo', '|',
			/* 'fullscreen', 
			'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
			'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
			'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
			'directionalityltr', 'directionalityrtl', 'indent', '|',
			'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
			'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
			 */
			'simpleupload', 'insertimage', 'emotion', 'scrawl', 'insertvideo',
			/* 'music', 
			'attachment',  */
			/* 'map', 'gmap', 'insertframe', */
			'insertcode'
			/* 'webapp', 'pagebreak', 'template', 'background', '|', */
			/* 'horizontal', 'date', 'time', 'spechars', 'snapscreen', 'wordimage', '|',
			'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts', '|',
			'print', 'preview', 'searchreplace', 'help', 'drafts'
			 */
			] ],
			elementPathEnabled : false,
			wordCount : false,
			serverUrl : "/ksp/uedi",
			zIndex : 0
		});
		
		//板块主题 二级联动
		$.ajax({
			 url : "/ksp/boa/KSPB014"
			,type : "get"
			,dataType : "json"
			,success : function(res) {
				var ops = "";
				/* var boaArr = eval(res.jdt);
				for (var i = 0; i < boaArr.length; i++) {
					var boa = boaArr[i];
					ops += '<option value="' + boa.BOA_TCH + '">' + boa.BOA_NAM + '</option>';
				} */
				ops += '<option value="100001">工作平台</option>';
				ops += '<option value="100002">微服务</option>';
				$("#BOA_TCH").append(ops);
				form.render();
				//iniThe(baoArr[0].BOA_TCH);
				iniThe("a");
			}
		});
		
		form.on("select(boa)", function(boaDta) {
			iniThe(boaDta.value);
		});
	}
	
	function iniThe(boaTch) {
		$.ajax({
			 url : "/ksp/boa/KSPB024"
			,type : "get"
			,dataType : "json"
			,data : {"BOA_TCH" : boaTch}
			,success : function(res) {
				var ops = "";
				/* var theArr = eval(res.jdt);
				for (var i = 0; i < theArr.length; i++) {
					var the = theArr[i];
					ops += '<option value="' + the.THE_TCH + '">' + the.THE_NAM + '</option>';
				} */
				ops += '<option value="100001">问题求助</option>';
				ops += '<option value="100002">上线须知</option>';
				$("#TOP_TCH").empty();
				$("#TOP_TCH").append(ops);
				form.render();
			}
		});
	}
	
	function oprArt() {
		$("#bAdd").click(function() {
			var boaTch = $("#BOA_TCH").val();
			var topTch = $("#TOP_TCH").val();
			var kspTtl = $("#KSP_TTL").val();
			var conCon = UE.getEditor("CON_CON").getContent();
			var req = {
					"BOA_TCH" : boaTch,
					"TOP_TCH" : topTch,
					"TTL_TTL" : kspTtl,
					"CON_CON" : conCon
			};
			
			$.ajax({
				 url : "/ksp/art/KSPA01"
				,type : "post"
				,dataType : "json"
				,data : req
				,success : function(res) {
					if (res.cod == "200") {
						layer.msg("添加成功", {
							icon : 6
							,btn : ['确认']
							,yes : function(index, layero) {
								window.location.href="/ksp/p/artlst";
								
							}
						})
					} else {
						alert(res.msg);
					}
				}
			});
		});
	}
</script>
<script type="text/javascript">
	$(function() {
		iniNar();
		loginchk();
		iniform();
		oprArt();
	});
</script>

</head>
<body>
	<div id="navDiv"></div>
	<div
		style="margin-top: 20px; margin-left: 20px; width: 1300px; heigth: 100%;">
		<div style="background-color: #eff;">
			<a href="/ksp/index">首页</a>-><a href="/ksp/p/art/artlst">文章</a> -> 新增
		</div>

		<form class="layui-form" style="padding-top: 20px;">
			<div class="layui-form-item">
				<label>板块</label>
				<div class="layui-inline">
					<select id="BOA_TCH" lay-filter="boa"></select>
				</div>
				&nbsp;&nbsp;<label>主题</label>
				<div class="layui-inline" style="width: 120px;">
					<select id="TOP_TCH"></select>
				</div>
			</div>

			<div class="layui-form-item">
				文章标题<input class="layui-input" name="TTL_TTL" id="KSP_TTL" required
					lay-verify="required" placeholder="简要概述你的问题" autocomplete="off" />
			</div>
			<div class="layui-form-item">
				文章内容
				<textarea id="CON_CON" name="CON_CON" style="height: 400px;"></textarea>
			</div>

			<div style="padding-top: 5px;">
				<button class="layui-btn" type="button" id="bAdd" data-type="subTsk">提交</button>
			</div>
		</form>
	</div>
</body>
</html>